package cn.dglydrpy.study.j2ee.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.dglydrpy.study.j2ee.manage.dao.EmpDAO;
import cn.dglydrpy.study.j2ee.manage.entity.Emp;


public class ListEmpServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(
			HttpServletRequest request,
			HttpServletResponse response) 
		throws ServletException, IOException {
		EmpDAO dao = new EmpDAO();
		List<Emp> list = dao.findAll();
		
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		out.println("<!DOCTYPE html>");
		out.println("<html>");
		out.println("<head>");
		out.println("<meta charset=\"UTF-8\">");
		out.println("</head>");
		out.println("<body>");
		out.println("<h1>Ա���б�</h1>");
		
		out.println("<table border='1'>");
		out.println("<tr>");
		out.println("<td>���</td>");
		out.println("<td>����</td>");
		out.println("<td>�쵼</td>");
		out.println("<td>��ְ����</td>");
		out.println("<td>���ź�</td>");
		out.println("<td>н��</td>");
		out.println("<td>���</td>");
		out.println("</tr>");
		for(Emp emp : list) {
			out.println("<tr>");
			out.println("<td>"+emp.getEmpno()+"</td>");
			out.println("<td>"+emp.getEname()+"</td>");
			out.println("<td>"+emp.getMgr()+"</td>");
			out.println("<td>"+emp.getHiredate()+"</td>");
			out.println("<td>"+emp.getDeptno()+"</td>");
			out.println("<td>"+emp.getSalary()+"</td>");
			out.println("<td>"+emp.getComm()+"</td>");
			out.println("</tr>");
		}
		out.println("</table>");
		out.println("</body>");
		out.println("</html>");
	}
}
